package com.abner.design.patterns.factory.simplefactory.optimization;

import com.abner.design.patterns.factory.simplefactory.pizza.CheesePizza;
import com.abner.design.patterns.factory.simplefactory.pizza.GreekPizza;
import com.abner.design.patterns.factory.simplefactory.pizza.PepperPizza;
import com.abner.design.patterns.factory.simplefactory.pizza.Pizza;

/**
 * 披萨工厂类(简单工厂模式 也叫 静态工厂模式)
 * @Author: abner
 * @Date: 2022-04-23-21:39
 **/
public class PizzaFactory {

    /**
     * 获取披萨
     * @param orderType
     * @return
     */
    public static Pizza getPizza(String orderType) {

        Pizza pizza = null;

        if ("greek".equals(orderType)) {
            pizza = new GreekPizza();
            pizza.setName("希腊披萨");
        } else if ("cheese".equals(orderType)) {
            pizza = new CheesePizza();
            pizza.setName("奶酪披萨");
        } else if ("pepper".equals(orderType)) {
            pizza = new PepperPizza();
            pizza.setName("胡椒披萨");
        }

        return pizza;
    }
}
